library(readr)
library(tidyverse)
library(dplyr)
package ‘dplyr’ was built under R version 3.6.2
Attaching package: ‘dplyr’

The following objects are masked from ‘package:stats’:

    filter, lag

The following objects are masked from ‘package:base’:

    intersect, setdiff, setequal, union
library(janitor)
package ‘janitor’ was built under R version 3.6.2
Attaching package: ‘janitor’

The following objects are masked from ‘package:stats’:

    chisq.test, fisher.test
install.packages("here")
trying URL 'https://cran.rstudio.com/bin/macosx/el-capitan/contrib/3.6/here_0.1.tgz'
Content type 'application/x-gzip' length 18187 bytes (17 KB)
==================================================
downloaded 17 KB

The downloaded binary packages are in
    /var/folders/8t/s1y_vz7x589_hpgh_gmsk1vr0000gn/T//RtmpJxujx7/downloaded_packages
install.packages("readxl")
Error in install.packages : Updating loaded packages
install.packages("readxl")
trying URL 'https://cran.rstudio.com/bin/macosx/el-capitan/contrib/3.6/readxl_1.3.1.tgz'
Content type 'application/x-gzip' length 1646895 bytes (1.6 MB)
==================================================
downloaded 1.6 MB

The downloaded binary packages are in
    /var/folders/8t/s1y_vz7x589_hpgh_gmsk1vr0000gn/T//RtmpSAgBw6/downloaded_packages
library(readxl)

Task 4 - Decathlon Data

candy_2015 <- read_excel("boing-boing-candy-2015.xlsx")
candy_2015
NA
head(candy_2015)
dim(candy_2015)
[1] 5630  124
names(dim(candy_2015))
NULL
names(candy_2015)
  [1] "Timestamp"                                                                                                        
  [2] "How old are you?"                                                                                                 
  [3] "Are you going actually going trick or treating yourself?"                                                         
  [4] "[Butterfinger]"                                                                                                   
  [5] "[100 Grand Bar]"                                                                                                  
  [6] "[Anonymous brown globs that come in black and orange wrappers]"                                                   
  [7] "[Any full-sized candy bar]"                                                                                       
  [8] "[Black Jacks]"                                                                                                    
  [9] "[Bonkers]"                                                                                                        
 [10] "[Bottle Caps]"                                                                                                    
 [11] "[Box’o’ Raisins]"                                                                                                 
 [12] "[Brach products (not including candy corn)]"                                                                      
 [13] "[Bubble Gum]"                                                                                                     
 [14] "[Cadbury Creme Eggs]"                                                                                             
 [15] "[Candy Corn]"                                                                                                     
 [16] "[Vials of pure high fructose corn syrup, for main-lining into your vein]"                                         
 [17] "[Candy that is clearly just the stuff given out for free at restaurants]"                                         
 [18] "[Cash, or other forms of legal tender]"                                                                           
 [19] "[Chiclets]"                                                                                                       
 [20] "[Caramellos]"                                                                                                     
 [21] "[Snickers]"                                                                                                       
 [22] "[Dark Chocolate Hershey]"                                                                                         
 [23] "[Dental paraphenalia]"                                                                                            
 [24] "[Dots]"                                                                                                           
 [25] "[Fuzzy Peaches]"                                                                                                  
 [26] "[Generic Brand Acetaminophen]"                                                                                    
 [27] "[Glow sticks]"                                                                                                    
 [28] "[Broken glow stick]"                                                                                              
 [29] "[Goo Goo Clusters]"                                                                                               
 [30] "[Good N' Plenty]"                                                                                                 
 [31] "[Gum from baseball cards]"                                                                                        
 [32] "[Gummy Bears straight up]"                                                                                        
 [33] "[Creepy Religious comics/Chick Tracts]"                                                                           
 [34] "[Healthy Fruit]"                                                                                                  
 [35] "[Heath Bar]"                                                                                                      
 [36] "[Hershey’s Kissables]"                                                                                            
 [37] "[Hershey’s Milk Chocolate]"                                                                                       
 [38] "[Hugs (actual physical hugs)]"                                                                                    
 [39] "[Jolly Rancher (bad flavor)]"                                                                                     
 [40] "[Jolly Ranchers (good flavor)]"                                                                                   
 [41] "[Kale smoothie]"                                                                                                  
 [42] "[Kinder Happy Hippo]"                                                                                             
 [43] "[Kit Kat]"                                                                                                        
 [44] "[Hard Candy]"                                                                                                     
 [45] "[Lapel Pins]"                                                                                                     
 [46] "[LemonHeads]"                                                                                                     
 [47] "[Licorice]"                                                                                                       
 [48] "[Licorice (not black)]"                                                                                           
 [49] "[Lindt Truffle]"                                                                                                  
 [50] "[Lollipops]"                                                                                                      
 [51] "[Mars]"                                                                                                           
 [52] "[Mary Janes]"                                                                                                     
 [53] "[Maynards]"                                                                                                       
 [54] "[Milk Duds]"                                                                                                      
 [55] "[LaffyTaffy]"                                                                                                     
 [56] "[Minibags of chips]"                                                                                              
 [57] "[JoyJoy (Mit Iodine)]"                                                                                            
 [58] "[Reggie Jackson Bar]"                                                                                             
 [59] "[Pixy Stix]"                                                                                                      
 [60] "[Nerds]"                                                                                                          
 [61] "[Nestle Crunch]"                                                                                                  
 [62] "[Now'n'Laters]"                                                                                                   
 [63] "[Pencils]"                                                                                                        
 [64] "[Milky Way]"                                                                                                      
 [65] "[Reese’s Peanut Butter Cups]"                                                                                     
 [66] "[Tolberone something or other]"                                                                                   
 [67] "[Runts]"                                                                                                          
 [68] "[Junior Mints]"                                                                                                   
 [69] "[Senior Mints]"                                                                                                   
 [70] "[Mint Kisses]"                                                                                                    
 [71] "[Mint Juleps]"                                                                                                    
 [72] "[Mint Leaves]"                                                                                                    
 [73] "[Peanut M&M’s]"                                                                                                   
 [74] "[Regular M&Ms]"                                                                                                   
 [75] "[Mint M&Ms]"                                                                                                      
 [76] "[Ribbon candy]"                                                                                                   
 [77] "[Rolos]"                                                                                                          
 [78] "[Skittles]"                                                                                                       
 [79] "[Smarties (American)]"                                                                                            
 [80] "[Smarties (Commonwealth)]"                                                                                        
 [81] "[Chick-o-Sticks (we don’t know what that is)]"                                                                    
 [82] "[Spotted Dick]"                                                                                                   
 [83] "[Starburst]"                                                                                                      
 [84] "[Swedish Fish]"                                                                                                   
 [85] "[Sweetums]"                                                                                                       
 [86] "[Those odd marshmallow circus peanut things]"                                                                     
 [87] "[Three Musketeers]"                                                                                               
 [88] "[Peterson Brand Sidewalk Chalk]"                                                                                  
 [89] "[Peanut Butter Bars]"                                                                                             
 [90] "[Peanut Butter Jars]"                                                                                             
 [91] "[Trail Mix]"                                                                                                      
 [92] "[Twix]"                                                                                                           
 [93] "[Vicodin]"                                                                                                        
 [94] "[White Bread]"                                                                                                    
 [95] "[Whole Wheat anything]"                                                                                           
 [96] "[York Peppermint Patties]"                                                                                        
 [97] "Please leave any remarks or comments regarding your choices."                                                     
 [98] "Please list any items not included above that give you JOY."                                                      
 [99] "Please list any items not included above that give you DESPAIR."                                                  
[100] "Guess the number of mints in my hand."                                                                            
[101] "Betty or Veronica?"                                                                                               
[102] "Check all that apply: \"I cried tears of sadness at the end of  ____________\""                                   
[103] "\"That dress* that went viral early this year - when I first saw it, it was ________\""                           
[104] "Fill in the blank: \"Taylor Swift is a force for ___________\""                                                   
[105] "What is your favourite font?"                                                                                     
[106] "If you squint really hard, the words \"Intelligent Design\" would look like."                                     
[107] "Fill in the blank: \"Imitation is a form of ____________\""                                                       
[108] "Please estimate the degree(s) of separation you have from the following celebrities [JK Rowling]"                 
[109] "Please estimate the degree(s) of separation you have from the following celebrities [JJ Abrams]"                  
[110] "Please estimate the degree(s) of separation you have from the following celebrities [Beyoncé]"                    
[111] "Please estimate the degree(s) of separation you have from the following celebrities [Bieber]"                     
[112] "Please estimate the degree(s) of separation you have from the following celebrities [Kevin Bacon]"                
[113] "Please estimate the degree(s) of separation you have from the following celebrities [Francis Bacon (1561 - 1626)]"
[114] "[Sea-salt flavored stuff, probably chocolate, since this is the \"it\" flavor of the year]"                       
[115] "[Necco Wafers]"                                                                                                   
[116] "Which day do you prefer, Friday or Sunday?"                                                                       
[117] "Please estimate the degrees of separation you have from the following folks [Bruce Lee]"                          
[118] "Please estimate the degrees of separation you have from the following folks [JK Rowling]"                         
[119] "Please estimate the degrees of separation you have from the following folks [Malala Yousafzai]"                   
[120] "Please estimate the degrees of separation you have from the following folks [Thom Yorke]"                         
[121] "Please estimate the degrees of separation you have from the following folks [JJ Abrams]"                          
[122] "Please estimate the degrees of separation you have from the following folks [Hillary Clinton]"                    
[123] "Please estimate the degrees of separation you have from the following folks [Donald Trump]"                       
[124] "Please estimate the degrees of separation you have from the following folks [Beyoncé Knowles]"                    
view(candy_2015)
Error in view(candy_2015) : could not find function "view"
candy_2016 <- read_excel("boing-boing-candy-2016.xlsx")
candy_2016
candy_2017 <- read_excel("boing-boing-candy-2017.xlsx")
New names:
* `` -> ...114
candy_2017

select and clean columns by position

candy_2015_clean <- candy_2015 %>%
select(c(2:96))
candy_2016_clean <- candy_2016 %>%
select(c(2:5,7:106))
candy_2017_clean <- candy_2017 %>%
select(c(2:5,7:109))

clean the column names

candy_2015_clean <- clean_names(candy_2015_clean)
candy_2016_clean <- clean_names(candy_2016_clean)
candy_2017_clean <- clean_names(candy_2017_clean)

check data

#glimpse(candy_2015_clean)
#glimpse(candy_2016_clean)
#glimpse(candy_2017_clean)

#Data type
typeof(candy_2015_clean)
[1] "list"
typeof(candy_2016_clean)
[1] "list"
typeof(candy_2017_clean)
[1] "list"

Year column

LS0tCnRpdGxlOiAiUiBOb3RlYm9vayIKb3V0cHV0OiBodG1sX25vdGVib29rCi0tLQoKYGBge3J9CmxpYnJhcnkocmVhZHIpCmBgYAoKYGBge3J9CmxpYnJhcnkodGlkeXZlcnNlKQpgYGAKCmBgYHtyfQpsaWJyYXJ5KGRwbHlyKQpgYGAKCmBgYHtyfQpsaWJyYXJ5KGphbml0b3IpCmBgYAoKCmBgYHtyfQppbnN0YWxsLnBhY2thZ2VzKCJoZXJlIikKYGBgCgpgYGB7cn0KaW5zdGFsbC5wYWNrYWdlcygicmVhZHhsIikKYGBgCgpgYGB7cn0KbGlicmFyeShyZWFkeGwpCmBgYAoKClRhc2sgNCAtIERlY2F0aGxvbiBEYXRhCmBgYHtyfQpjYW5keV8yMDE1IDwtIHJlYWRfZXhjZWwoImJvaW5nLWJvaW5nLWNhbmR5LTIwMTUueGxzeCIpCmNhbmR5XzIwMTUKCmBgYAoKYGBge3J9CmhlYWQoY2FuZHlfMjAxNSkKZGltKGNhbmR5XzIwMTUpCm5hbWVzKGRpbShjYW5keV8yMDE1KSkKbmFtZXMoY2FuZHlfMjAxNSkKYGBgCgpgYGB7cn0KdmlldyhjYW5keV8yMDE1KQpgYGAKCgpgYGB7cn0KY2FuZHlfMjAxNiA8LSByZWFkX2V4Y2VsKCJib2luZy1ib2luZy1jYW5keS0yMDE2Lnhsc3giKQpjYW5keV8yMDE2CmBgYAoKYGBge3J9CmNhbmR5XzIwMTcgPC0gcmVhZF9leGNl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